#!/usr/bin/env python
#coding:utf-8
 
from wsgiref.simple_server import make_server
import time
from jinja2 import Template

def index():
    data = open('html/index.html').read()
    current_time = str(time.time())
    template=Template(data)
    result = template.render(
        name="tom",
        age = "83",
        current_time=current_time,
        user_list=['tom','jack'],
        num=1
    )
    return result.encode('utf-8')

def RunServer(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    return index()
 
if __name__ == '__main__':
    httpd = make_server('', 8000, RunServer)
    print "Serving HTTP on port 8000..."
    httpd.serve_forever()